<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Send extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	
	public $base_uri = array();
			
	function __construct(){
			parent::__construct();
			$main =   & get_config();
			$this->base_uri['base_url'] = $main['base_url'];
	
	}
		
	public function index()
	{
		echo "debug";
	}
	
	public function mail()
	{
		$this->load->model('Sendmodel');
		$result = $this->Sendmodel->put();
		
		$this->load->library('email');
		
		echo '<div style="color: #fff">';
		foreach($result as $row){
			if($row->status == "1"){
				$mes = "угадали счет";
			}else{
				$mes = "угадали результат";
			}
			$mes = 'Вы '.$mes.' в матче '.$row->name.'. Вам начислено:'.$row->ball.' баллов.';
			echo $mes;
			$this->email->from('your@dozor.ru', 'Пивной Дозор');
			$this->email->to($row->email);
			$this->email->subject('Начисление баллов');
			$this->email->message($mes);
			$this->email->send();
		}
		echo '</div>';
		$this->email->print_debugger();
		
		/*
		$this->load->library('email');
		
		for($i=0; $i<5; $i++){
			$this->email->from('your@your-site.com', 'Your Name');
			$this->email->to('fox7812@rambler.ru');

			$this->email->subject('Тест Email');
			$this->email->message('Тестирование класса отправки сообщений');

			$this->email->send();
		}

		$this->email->print_debugger();*/
	}
	
	
}

